#include <bits/stdc++.h>
using namespace std;
void min_path(vector<int>& a,int col,int x,int y,int& value){
    if(x<=col||y<=col)
    {
        if(x == col-1&& y == col-1)
        {
            cout<<value<<endl;
        }
        else if(x == col-1&& y != col-1)
        {
            int temp = value+a[x*col+y+1];
            min_path(a,col,x,y+1,temp);

        }
        else if(x != col-1&& y == col-1){
            int temp = value+a[(x+1)*col+y];
            min_path(a,col,x+1,y,temp);
        } else{
            int temp = 0;
            if(a[x*col+y+1]<a[(x+1)*col+y])
            {
                temp = value+a[x*col+y+1];
                min_path(a,col,x,y+1,temp);
            }
            else{
                temp = value+a[(x+1)*col+y];
                min_path(a,col,x+1,y,temp);
            }
        }

    }

}
int main() {
    vector<int> a = {1,3,5,9,8,1,3,4,5,0,6,1,8,8,4,0};
    int m = 0,n = 0;
    int value = a[0];
    min_path(a,4,m,n,value);
    return 0;
}